home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / eflibpt4.zip / DEMO / DATATYPE / LINKASR2.PAS < prev    next >
Pascal/Delphi Source File  |  1996-08-18  |  2KB  |  63 lines

  1. { Borland Pascal Extended Function Library - EFLIB (C) Johan Larsson, 1996
  2.   Demonstration; linked list active sort performance test
  3.  
  4.   EFLIB IS PROTECTED BY THE COPYRIGHT LAW AND MAY NOT BE COPIED, SOLD OR
  5.   MANIPULATED. FOR MORE INFORMATION, SEE PROGRAM MANUAL! THIS DEMONSTRAT-
  6.   ION PROGRAM MAY FREELY BE USED AND DISTRIBUTED.                          }
  7.  
  8.  
  9. uses EFLIBDEF, EFLIBINI, EFLIBBAS, EFLIBDAT;
  10.  
  11.  
  12. const Filename = '..\data.txt';
  13.  
  14. var MyText : TextObjectType; Index : word;
  15.     Timer : TimerObjectType;
  16.     TextFile : text; SomeData : string;
  17.  
  18.  
  19. procedure AddInOrder;
  20. begin
  21.      System.Assign (TextFile, Filename); Reset (TextFile);
  22.      while not Eof(TextFile) do begin
  23.            ReadLn (TextFile, SomeData);
  24.            MyText.Add (SomeData);
  25.      end;
  26.      System.Close (TextFile);
  27. end;
  28.  
  29.  
  30. begin
  31.      with MyText do begin
  32.           { Initialize a structure based on text strings }
  33.           Initialize;
  34.  
  35.           { Enable active sorting with ascending sort order }
  36.           SetAscendingOrder;
  37.  
  38.           Timer.Initialize;
  39.  
  40.           { Binary search method }
  41.           SetSearchMethod (BinarySearchMethod);
  42.           AddInOrder;
  43.           WriteLn ('Active sorting with *FAST* binary search;');
  44.           WriteLn ('':3, Timer.StringMS);
  45.           if not (IsSorted(AscendingOrder) and IsIntact)
  46.              then WriteLn ('Test; structure sorting failed.');
  47.  
  48.           Clear; { Clear all elements }
  49.  
  50.           Timer.Reset;
  51.  
  52.           { Linear search method }
  53.           SetSearchMethod (LinearSearchMethod);
  54.           AddInOrder;
  55.           WriteLn ('Active sorting with conventional linear search;');
  56.           WriteLn ('':3, Timer.StringMS);
  57.           if not (IsSorted(AscendingOrder) and IsIntact)
  58.              then WriteLn ('Test; structure sorting failed.');
  59.  
  60.           Intercept; Timer.Intercept;
  61.      end;
  62.      if GlobalDataError then WriteLn ('Error(s) reported!');
  63. end.